package com.sduept.nwld.dataserver.manager.message;

import com.sduept.component.message.model.MessageListenerInfo;
import com.sduept.core.dao.SuperDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
@Service
public class MessageListenerManager {
	@Autowired
	private SuperDAO dao;
	public void saveMessageAccepter(String messageTopic){
		 try {
			InetAddress ia=InetAddress.getLocalHost();
			MessageListenerInfo mi = new MessageListenerInfo();
			mi.setDate(new Date());
			mi.setAccepter(ia.getHostAddress());
			mi.setTopic(messageTopic);
			dao.createOrUpdate(mi, MessageListenerInfo.class);
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}
}
